using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[Serializable]
public class TimedMobKillEvent : KillEvent, ITimedEvent
{
	public int neededKills;

	public float neededTime;

	public bool disableIfAchieved = true;

	public bool achieved;

	public bool onlineKill;

	public bool IfEvent(KillInfo newKill, List<KillInfo> KillsIList)
	{
		if (onlineKill != newKill.onlineKill)
		{
			return false;
		}
		if (weaponType != WeaponType.Non && weaponType != newKill.weaponType)
		{
			return false;
		}
		if (enemyType != newKill.enemyType)
		{
			return false;
		}
		if (achieved)
		{
			return false;
		}
		int num = 1;
		foreach (KillInfo KillsI in KillsIList)
		{
			if (KillsI.enemyType == enemyType && newKill.time - KillsI.time <= neededTime)
			{
				num++;
				if (num == neededKills)
				{
					return true;
				}
			}
		}
		return false;
	}

	public IEnumerator DisableForTime()
	{
		AddToAchidedList();
		if (disableIfAchieved)
		{
			achieved = true;
		}
		yield return new WaitForSeconds(neededTime);
		Reset();
	}

	public void AddToAchidedList()
	{
		GameplayEventsManager.instance.allTimedEvents.Add(this);
	}

	public void Reset()
	{
		achieved = false;
	}
}
